
//获取需要处理的DOM元素
var scroll_begin = document.getElementById("scroll_begin");
var scroll_end = document.getElementById("scroll_end");
var scroll_box = document.getElementById("scroll_box");


scroll_begin.style.height=scroll_box.offsetWidth+"px";
scroll_end.height=scroll_box.offsetWidth+"px";
//复制图片元素
scroll_end.innerHTML = scroll_begin.innerHTML;

//设置滚动区域
scroll_box.scrollLeft = 5;


function marquee(){
    // console.log(scroll_box.scrollLeft);
    if(scroll_box.scrollLeft >= scroll_box.offsetWidth){
        scroll_box.scrollLeft =0;
    }else{
        scroll_box.scrollLeft++;
    }
}

//定时滚动
var flag = window.setInterval("marquee()", 50);

//鼠标事件
scroll_box.addEventListener(
    "mouseover",
    function () {
        clearInterval(flag);
    }
);

scroll_box.addEventListener(
    "mouseout",
    function () {
        flag = setInterval(marquee, speed);
    }
);



